package bridge;

/**
 * 两个纬度去发展事物的本身
 * 1、实体的
 * 2、抽象的
 */
interface DoIt{
    void say();
}

/**
 * 抽象的
 */
abstract class Gift implements DoIt{
    // 抽象的采用聚合的方式聚合实体的
    GiftImp giftImp;
}

/**
 * 实体的
 */
abstract class GiftImp implements DoIt{

}

/**
 * 实体的发展
 */
class Book extends GiftImp {

    @Override
    public void say() {
        System.out.println("book");
    }
}
class Flower extends GiftImp{

    @Override
    public void say() {
        System.out.println("flower");
    }
}

/**
 * 抽象的发展
 */
class WarmGift extends Gift{
    WarmGift(GiftImp giftImp){
        this.giftImp = giftImp;
    }
    @Override
    public void say() {
        System.out.println("温暖的礼物");
        giftImp.say();
    }
}

class GoldGift extends Gift{
    GoldGift(GiftImp giftImp){
        this.giftImp = giftImp;
    }

    @Override
    public void say() {
        System.out.println("冷酷的礼物");
        giftImp.say();
    }
}

public class Bridge {
    public static void main(String[] args) {
        System.out.println("bridge");

        Gift gift = new WarmGift(new Book());
        Gift gift1 = new GoldGift(new Flower());
        gift.say();
        gift1.say();
    }
}
